﻿using System.Linq.Expressions;
using PropertyExpression.Common;

namespace PropertyExpression.RelationalDataInstance
{
    public static class DataTuple
    {
        public static TResult GetValue<TEntity, TResult>(
            this IDataTuple<TEntity> it,
            Expression<Func<TEntity, TResult>> propertyExpression)
        {
            return it.GetValue(propertyExpression.ToPropertyExpressionProxy());
        }

        public static Action<TResult> SetValue<TEntity, TResult>(
            this IDataTuple<TEntity> it,
            Expression<Func<TEntity, TResult>> propertyExpression)
        {
            return it.SetValue(propertyExpression.ToPropertyExpressionProxy());
        }

        public static IDataTuple<TResult> GetRef<TEntity, TResult>(
            this IDataTuple<TEntity> it,
            Expression<Func<TEntity, TResult>> propertyExpression)
        {
            return it.GetRef(propertyExpression.ToPropertyExpressionProxy());
        }

        public static Action<IDataTuple<TResult>> SetRef<TEntity, TResult>(
            this IDataTuple<TEntity> it,
            Expression<Func<TEntity, TResult>> propertyExpression)
        {
            return it.SetRef(propertyExpression.ToPropertyExpressionProxy());
        }

        public static IEnumerable<IDataTuple<TResult>> GetValue<TEntity, TResult>(
            this IDataTuple<TEntity> it,
            Expression<Func<TEntity, IEnumerable<TResult>>> propertyExpression)
        {
            return it.GetValue(propertyExpression.ToPropertyExpressionProxy());
        }
    }
}